import Vue from 'vue'
import VueRouter from 'vue-router'
const Home = () => import(/* webpackChunkName:"home" */ '@/views/Home/Home.vue')
const TopList = () => import(/* webpackChunkName:"toplist" */ '@/views/TopList/TopList.vue')
const SongDetail = () => import(/* webpackChunkName:"songdetail" */ '@/views/SongDetail/SongDetail.vue')
const PlayList = () => import(/* webpackChunkName:"playlist" */ '@/views/PlayList/PlayList.vue')
const PlayListDetail = () => import(/* webpackChunkName:"playlist" */ '@/views/PlayList/PlayListDetail/PlayListDetail.vue')
const RadioIndex = () => import(/* webpackChunkName:"radio" */ '@/views/Radio/RadioIndex/RandioIndex.vue')
const RadioCate = () => import(/* webpackChunkName:"radio" */ '@/views/Radio/RadioCate/RadioCate.vue')
const Recommend = () => import(/* webpackChunkName:"radio" */ '@/views/Radio/RadioRecom/RadioRecom.vue')
const Rank = () => import(/* webpackChunkName:"radio" */ '@/views/Radio/RadioRank/RadioRank.vue')
const RadioDetail = () => import(/* webpackChunkName:"radio" */ '@/views/Radio/RadioDetail/RadioDetail.vue')
const Program = () => import(/* webpackChunkName:"radio" */ '@/views/Radio/Program/Program.vue')
const ArtistIndex = () => import(/* webpackChunkName:"artist" */ '@/views/Artist/ArtistIndex/ArtistIndex.vue')
const ArtistSigned = () => import(/* webpackChunkName:"artist" */ '@/views/Artist/Signed/ArtistSigned.vue')
const ArtistDetail = () => import(/* webpackChunkName:"artist" */ '@/views/Artist/ArtistDetail/ArtistDetail.vue')
const ArtistAlbum = () => import(/* webpackChunkName:"artist" */ '@/views/Artist/ArtistAlbum/ArtistAlbum.vue')
const ArtistMv = () => import(/* webpackChunkName:"artist" */ '@/views/Artist/ArtistMv/ArtistMv.vue')
const ArtistDesc = () => import(/* webpackChunkName:"artist" */ '@/views/Artist/ArtistDesc/ArtistDesc.vue')
const Album = () => import(/* webpackChunkName:"album" */ '@/views/Album/Album.vue')
const AlbumDetail = () => import(/* webpackChunkName:"album" */ '@/views/Album/AlbumDetail/AlbumDetail.vue')
const UserHome = () => import(/* webpackChunkName:"userhome" */ '@/views/User/UserHome/UserHome.vue')
const NotFound = () => import(/* webpackChunkName:"notfound" */ '@/views/NotFound/NotFound.vue')

Vue.use(VueRouter)

const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/discover',
    component: Home
  },
  {
    path: '/discover/toplist',
    component: TopList
  },
  { path: '/discover/playlist', component: PlayList },
  { path: '/playlist', component: PlayListDetail },
  { path: '/song', component: SongDetail },
  {
    path: '/discover/djradio',
    component: RadioIndex
  },
  {
    path: '/discover/djradio/category',
    component: RadioCate
  },
  { path: '/discover/djradio/recommend', component: Recommend },
  { path: '/discover/djradio/rank', component: Rank },
  { path: '/djradio', component: RadioDetail },
  { path: '/program', component: Program },
  { path: '/discover/artist', component: ArtistIndex },
  { path: '/discover/artist/signed', component: ArtistSigned },
  {
    path: '/artist',
    component: ArtistDetail,
    children: [
      { path: '/artist/album', component: ArtistAlbum },
      { path: '/artist/mv', component: ArtistMv },
      { path: '/artist/desc', component: ArtistDesc }
    ]
  },
  { path: '/discover/album', component: Album },
  { path: '/album', component: AlbumDetail },
  { path: '/user/home', component: UserHome },
  {
    path: '/404',
    component: NotFound
  },
  {
    path: '*',
    redirect: '/404'
  }
]

const router = new VueRouter({
  routes
})

export default router
